#pragma once
#include <MyGUI.h>
#include "OIS/OIS.h"
#include "MouseStateManage.h"
#include "InputManage.h"

class CInputSystem:
	public OIS::MouseListener,
	public OIS::KeyListener,
	public CMouseStateManage
{
public:
	CInputSystem();
	virtual ~CInputSystem();

	void createInput();
	void destroyInput();
	void captureInput(float lastFrame);
	void setInputViewSize(int _width, int _height);

	//virtual void injectMouseMove(int _absx, int _absy, int _absz) { }
	//virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id) { }
	//virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id) { }
	//virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) { }
	//virtual void injectKeyRelease(MyGUI::KeyCode _key) { }
	void RegKeyPressed(InputKeyDelegate _keyEvent) { execueKeyPressedFun = _keyEvent; };
	void RegkeyReleased(InputKeyDelegate _keyEvent) { execueKeyReleasedFun = _keyEvent; };

	void setMousePosition(int _x, int _y);
	void updateCursorPosition();

private:
	virtual bool mouseMoved(const OIS::MouseEvent& _arg);
	virtual bool mousePressed(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id);
	virtual bool mouseReleased(const OIS::MouseEvent& _arg, OIS::MouseButtonID _id);
	virtual bool keyPressed(const OIS::KeyEvent& _arg);
	virtual bool keyReleased(const OIS::KeyEvent& _arg);

	void checkPosition();
	KEYBOARDFS ConvertKeyCode(const OIS::KeyEvent& _arg);
private:
	int mCursorX;
	int mCursorY;

	InputKeyDelegate execueKeyPressedFun;
	InputKeyDelegate execueKeyReleasedFun;
};